<%@ page language="java" contentType="text/html; charset=utf-8" import="com.bjsxt.shopping.user.*,com.bjsxt.shopping.product.*"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>

<%
request.setCharacterEncoding("utf-8");
String action = request.getParameter("action");
System.out.println(action);
User u = (User)session.getAttribute("user");

//会话过期
if(null==u){
	response.sendRedirect("UserLogin.jsp");
	return;
}

String consumerid = u.getLoginname();
if(action != null){
   if(action.trim().equals("save") || action.trim().equals("modify")) {
	
	//int id = Integer.parseInt(request
	//		.getParameter("id"));
	System.out.println(action);
	String subject = request
			.getParameter("subject");
	System.out.println(consumerid);
	String urgency = request
			.getParameter("urgency");
	String article = request
			.getParameter("article");
	String content = request
			.getParameter("content");
	String wordsNum1 = content.replace(" ", "");
	String wordsNum2 = wordsNum1.replace(" ", "");		
	int wordsNum = wordsNum2.length();
	Double price=wordsNum*0.42;
	Product p1 = new Product();

	p1.setSubject(subject);
	p1.setPrice(price);
	p1.setUrgency(urgency);
	p1.setArticle(article);
	p1.setWordsNum(wordsNum);
	p1.setContent(content);
	p1.setConsumerid(consumerid);
	/* if(action.trim().equals("save")) {
		System.out.println("进入保存");
		p1.setSend_status("已保存");
		
	}else{
	*/
		System.out.println("进入提交");
		p1.setSend_status("订单已提交");
	
	 ProductMgr.getInstance().addNew(p1);
	response.sendRedirect("TransOrderSelfList.jsp");

	return;
  }
}

%>


<html>
	<head>

		<meta http-equiv="Content-Language" content="zh-cn">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>- 翻译订单提交</title>

		<link href="images/new.css" rel="stylesheet" type="text/css">
<script language="javascript1.2">
function countChar(textareaName)
{  
	var textlen = document.getElementById(textareaName).value.length;
	document.getElementById("wordsNum").innerHTML =textlen;
	
	var prices = textlen*0.42
	document.getElementById("price").innerHTML =Number(prices).toFixed(2);
} 

function js_callpage(htmlurl)
{
	var newwin=window.open(htmlurl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,top=2,width=360,height=470');
	return false;
}
function js_callpage1(htmlurl)
{
	var newwin=window.open(htmlurl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=2,width=100,height=100');
	return false;
}
function checkInput()
{
	var subjectStr = register.subject.value; 
	var contentStr = register.content.value; 
	if(trim(subjectStr)==""||null==subjectStr){
		alert('文章标题不能为空');
		register.action.value="noPass";
		register.subject.focus();
		return false;
	}
	
	if(trim(contentStr)==""||null==contentStr){
		alert('正文不能为空');
		register.action.value="noPass";
		register.content.focus();
		return false;
	}
	
	register.action.value="save";
	
}

function checkSave()
{
	checkInput();
	var action = register.action.value;
	if(action!="noPass"){
	register.action.value="save";
	}
}

	function trim(t){
		return (t||"").replace(/^\s+|\s+$/g, "");
	}

</script>




	</head>
	<body>
	<form method="post" name="register" action="" onSubmit="this.regsubmit.disabled=true;">
	<input type="hidden" name="action" value="modify"/>
	<input type="hidden" name="id" value=""/>
		<table align="center" border="0" cellpadding="0" cellspacing="0"
			width="980">
			<tbody>


				<tr>
					<td bgcolor="#dadce8" height="1">
						<img src="images/line.gif" height="1" width="1">
					</td>
				</tr>

				<tr>
					<td>
						<table border="0" cellpadding="0" cellspacing="0" width="100%">
							<tbody>
								<tr>
									<td bgcolor="#e5e5f0" valign="top" width="190">
										<img src="images/gg11.jpg" height="60" width="180">
									</td>
									<td width="10">
									</td>
									<td valign="top" width="780">
										<table style="border-collapse: collapse;" border="0"
											bordercolor="#111111" cellpadding="0" cellspacing="0"
											height="417" width="100%">
											<tbody>


												<tr>
													<td height="119">
														<table style="border-collapse: collapse;" border="0"
															bordercolor="#111111" cellpadding="0" cellspacing="0"
															width="100%">
															<tbody>
																<tr>
																	<td width="100%">
																		<input name="nowpcd" value="" type="hidden">
																		<table border="1" cellpadding="0" cellspacing="0"
																			width="100%">

																		
																			<tbody>



																				<tr>
																					<td bgcolor="#e5e5f0" height="25">
																						<table style="border-collapse: collapse;"
																							border="0" cellpadding="0" cellspacing="0"
																							width="100%">
																							<tbody>
																								<tr>
																									<td>
																										&nbsp;
																										<img src="images/m_33.gif" height="10"
																											width="10">
																										&nbsp;
																										<strong>
																											欢迎您，<%=consumerid %> 填写翻译订单
																										</strong> &nbsp;
																									</td>
																									<td align="right">
																									
																											<a href="AccIndex.jsp"><font style="font-weight:bold;color:blue;TEXT-DECORATION: underline; ">返回</font></a>
																										&nbsp;&nbsp;&nbsp;&nbsp;
																									</td>
																								</tr>


																							</tbody>
																						</table>
																					</td>

																				</tr>


																				<tr>
																					<td align="center" height="100">
																						<table style="border-collapse: collapse;"
																							bgcolor="#ffffff" border="0" cellpadding="0"
																							cellspacing="0" width="95%">
																							<tbody>
																								<tr>
																									<td rowspan="4" width="76"></td>
																									<td width="607">&nbsp;</td>
																									<td width="50"></td>																									
																									

																								</tr>
																								<tr>
																									<td width="50%">
                                                                                                                                                                                                                                                                                                                                                              文章标题: <input name="subject" type="text" style="width: 130px"><br>
																									</td>
																									<td>
																									 <font color="#cc0000"><span id="price" style="display:none;" ></span></font>
																									</td>
																									<td align="right" >
																										
																									</td>
																																																				
																								</tr>
																								<tr>
																								<td>紧&nbsp;迫&nbsp;度&nbsp;: <select name="urgency" onChange="changeselect1(this.value)"> 
	                                                                                                               <option value="">请选择文章紧迫度</option> 
                                                                                                                   <option value="紧急">紧急</option> 
                                                                                                                   <option value="一般">一般</option> 
                                                                                                                   <option value="不急">不急</option> 
                                                                                                                   </select> 
                                                                                                                   <br>
                                                                                                </td>
																								<td>
																									 文章性质: <select name="article" style="width: 130px"> 
	                                                                                                               <option value="">请选择文章性质</option> 
                                                                                                                   <option value="邮件">邮件</option> 
                                                                                                                   <option value="公文">公文</option> 
                                                                                                                   </select> 
																								</td>
																								<td align="right" >
																										
																									</td>
																								</tr>
																								<tr>
																								<td>   字&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数: <font color="#cc0000"><span id="wordsNum"></span></font>&nbsp;
																											&nbsp;<br></td>
																								<td></td>
																								<td align="right" >
																										
																									</td>
																								</tr>
																								<tr>
																									<td colspan="3" width="807">
																										&nbsp;<br>
																										&nbsp;&nbsp;&nbsp;正文:<br>
																										&nbsp;&nbsp; 
																										<textarea id="content" name="content" onkeydown="countChar('content');" onkeyup="countChar('content');" style="width: 98%;height: 330px;resize: none;"></textarea>
																									
																									</td>
																								</tr>
																								<tr>
																								<td colspan="3" align="right">
																									
																									&nbsp;&nbsp;&nbsp;<input name="regsubmit" value="提交" type="submit" onclick="return checkInput(this.form)" style="width:50px;height:30px;font-size:16px;">
																									&nbsp;&nbsp;																								
																								</td>
																								</tr>
																							</tbody>
																						</table>
																					</td>
																				</tr>
																			</tbody>
																		</table>
																	</td>
																</tr>

															</tbody>
														</table>
													</td>
												</tr>
												<tr>
													<td height="30">
													</td>
												</tr>
											</tbody>
										</table>
									</td>
								</tr>
							</tbody>
						</table>
					</td>
				</tr>
				<tr>
					<td width="100%">
						<!--底部INC--><br>
					</td>
				</tr>
			</tbody>
		</table>
	</form>
	</body>
</html>
